package com.xyq;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

public class MapPractice {
    public static void main(String[] args) {
        Map<String,String> data= new HashMap<>();
        data.put("阿未", "a");
        data.put("阿伟", "b");
        data.put("阿kar", "c");
        data.put("阿kar1", "d");
        data.put("阿kar2", "a");
        data.put("阿kar3", "b");
        data.put("阿kar4", "b");
        data.put("阿kar5", "c");
        data.put("阿kar6", "c");
        data.put("阿kar7", "c");
        data.put("阿kar8", "d");
        data.put("阿kar9", "a");
        data.put("阿kar10", "a");
        data.put("阿kar11", "b");
        data.put("阿kar12", "b");
        count(data);


        }

    public static void count(Map<String, String> data) {
        Map<String,Integer> resultMap = new HashMap<>();
        data.forEach((k,v)->{
            boolean containsKey = resultMap.containsKey(v);
            if(containsKey){
               Integer  oldCount = resultMap.get(v);
               resultMap.put(v, oldCount+1);
            }else{
                resultMap.put(v, 1);
            }

        });
        resultMap.forEach((k,v)->{
            System.out.println(k+"--"+v);
        });

    }

}

